<?
  
  //RBNS2  part 

  if(isset($this)&& is_object($this)){
  	$precompiled=$this->precompiled;   	
  }

  if( (isset($precompiled)&& $precompiled)	||(isset($GLOBALS['main_precompiled']) && $GLOBALS['main_precompiled'])){
	  	if(isset($return)&&$return)
	  	{
	       // echo "return works!";
	  		ob_start();
	  		eval("?>$ToRBNSParsing<?");
	  		$result=ob_get_contents();
	  		ob_end_clean();
	  		return $result;
	
	  	}
	  	else
	  	eval("?>$ToRBNSParsing<?");
  } 
  else{

	  if(trim($ToRBNSParsing)<>"")
	  {//jit part
	    
		    ob_start();
		    
		    
		    //echo "$_RBNS_CLASSES_DIR/rbns.php5";
		      if(empty($_RBNS_TemplCacheFN))
		      {
		        if(function_exists('_RBNS_CACHENAME'))
		        { // ��� ������ ��������� ��� �����
		            $_RBNS_TemplCacheFN=@_RBNS_CACHENAME();
		        }
		        else
		        {//�� ���������     
		            $_RBNS_TemplCacheFN="$_SERVER[DOCUMENT_ROOT]/cacheTempl_".md5($ToRBNSParsing).".php5";  
		        };
		      }; 
		    if (empty($_RBNS_TemplCachePolitic)||($_RBNS_TemplCachePolitic=='noncache')||empty($_RBNS_TemplCacheFN)|| (!file_exists($_RBNS_TemplCacheFN)) )
		    {
		      
		      //  echo "<br>COMPILE!";
		      
		        include_once "rbns_translator.php5"; 
		        include_once "rbns_varparse.php5"; 
		        
		        $p=new RBNS_parser();
			        
			        $p->data=$ToRBNSParsing; 
			        $p->parse();
			       
			        if(!create_function("","?>$p->parse_result<?")) 
			        {//wrong generated code!
			           
			            $fname="$_SERVER[DOCUMENT_ROOT]/temp/wrong_result.htm";
			        	$p->errorstream(" RESULT is not valid php-program! ",'user',"backtrace <pre>".var_export(debug_backtrace(),true)."</pre> look for $fname for code".(($currTemplate)?" current template=$currTemplate":""));
			            
			            if(!$fn=fopen($fname,'w'))  die("File $fname is not exists!");
			            fwrite($fn,$p->parse_result);
			            fclose($fn);
			           
			          
			        }
			        else 
			        {    
			           
			           if(!empty($_RBNS_TemplCacheFN))
			           { 
			                $fname=$_RBNS_TemplCacheFN;
			                
			                $p->parse_result=trim($p->parse_result);
			              
			               // set <!DOCTYPE as first line 	                
			                if(substr($p->parse_result,0,8)!='<!DOCTYPE' && preg_match('/((<!--rbns_start_include .+-->)+.+)(<!DOCTYPE.*>)/isU',$p->parse_result,$res)){
			                	$p->parse_result=str_replace($res[0],$res[3].$res[1],$p->parse_result);
			                	
			                }
			                
			                if(!$fn=fopen($fname,'w'))  die("File $fname is NOT VALID!");
			                fwrite($fn,$p->parse_result);
			                fclose($fn);
			           };     
			           
					   if(isset($return)&&$return)
					   {         
			               
			                ob_start(); 
			                eval("?>$p->parse_result<?"); 	           
			                $result=ob_get_contents();
			                ob_end_clean();
			               return $result;
			        
			            }
			            else
			                eval("?>$p->parse_result<?"); 
			             
			        };
			    
			    }
			    else
			    {
			      //  echo "<br>FROm CACHE!";
			        $fp = fopen($_RBNS_TemplCacheFN, "r");
			        $data = fread($fp, filesize($_RBNS_TemplCacheFN));
			        fclose($fp);
			        
			      
			         eval("?>$data<?"); 
			        //include($_RBNS_TemplCacheFN); slowly???
			         
			    };
			    
			    $RBNS_resJIT=ob_get_contents(); 
			    ob_end_clean();
			   // echo "<br>enter!";
			    echo $RBNS_resJIT;flush();
		  }
		  
		  
		  
		   else { echo "<font color=red> empty parsing string</font><br>";}; 
		//profile('endParser');   
		
		
		
	 
};
?>